<?php

namespace Iyting\Tiktok\MiniProgram\Trade;

use Iyting\Tiktok\Kernel\BaseClient;

class Client extends BaseClient
{
    protected  $baseUri = 'https://open.douyin.com/api/apps/trade/v2/';

    protected  $needClientToken  = true;


    public function createRefund($params)
    {
        return $this->httpPostJson('refund/create_refund',$params);
    }

    public function syncRefund($out_refund_no,$deny_message = '',$refund_audit_status = 1)
    {
        $data['out_refund_no'] = $out_refund_no;
        $data['refund_audit_status'] = $refund_audit_status;
        if(!empty($deny_message)) {
            $data['deny_message'] = $deny_message;

        }
        return $this->httpPostJson('refund/merchant_audit_callback',$data);

    }

    public function orderCps($orderId)
    {
        $data['out_order_no'] = $orderId;
        return $this->httpPostJson('order/query_cps',$data);

    }

    public function pushDelivery($out_order_no, $poi_info, $use_all = true, )
    {
        $data['out_order_no'] = $out_order_no;
        $data['poi_info'] = $poi_info;
        $data['use_all'] = $use_all;

        return $this->httpPostJson('fulfillment/push_delivery',$data);

    }

    public function createBook($bookData)
    {

        return $this->httpPostJson('book/create_book',$bookData);
    }
    public function queryBook($data)
    {

        return $this->httpPostJson('book/query_book',$data);
    }
}